<%@ page language="java"  pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
$(function(){
	$.extend($.fn.validatebox.defaults.rules, {
		eqPwd : {/* 验证两次密码是否一致功能 */
			validator : function(value, param) {
				return value == $(param[0]).val();
			},
			message : '密码不一致！'
		},
		minLength: { // 判断最小长度
			          validator: function (value, param) {
			              return value.length >= param[0];
			         },
			          message: '最少输入 {0} 个字符'
			     },
	     phoneOrMobile: {//验证手机或电话
			    	  validator: function (value) {
			    	     return /^(13|15|18)\d{9}$/i.test(value) || /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i.test(value);
			    	 },
			    	    message: '请填入手机或电话号码,如13688888888或020-8888888'
			    },
		chinese : {// 验证中文
                     validator : function(value) {
			    	     return /^[\u0391-\uFFE5]+$/i.test(value);
			    	  },
			    	    message : '请输入中文'
			    },
		logname: {// 验证用户名
			    	 validator: function (value) {
			    	     return /^[a-zA-Z][a-zA-Z0-9_]{2,12}$/i.test(value);
			    	  },
			    	    message: '用户名不合法（字母开头，允许3-13字节，允许字母数字下划线）'
	           },

	});
	$('#user_reg_regForm').form({
	      url : '${pageContext.request.contextPath}/userAction!reg.action',
	      success:function(r){
	      var obj=jQuery.parseJSON(r);
	      /* console.info(obj); */	
	      if(obj.success){
	         $('#user_reg_regDialog').dialog('close');
	      }
	      $.messager.show({
            title:'提示',
            msg:obj.msg
      });		
	}
});
	/* 回车提交功能 */
	$('#user_reg_regForm input').bind('keyup',function(event){
		if(event.keyCode=='13'){
			$('#user_reg_regForm').submit();
		}
	});
	/* window.setTimeout(function(){
		$('#user_reg_regForm input[name="name"]').focus();
	}, 0); */
});	
</script>
<div id="user_reg_regDialog" class="easyui-dialog" data-options="title:'注册',modal:true,closed:true,buttons:[{text:'注册',iconCls:'icon-edit',
		handler:function(){
		    $('#user_reg_regForm').submit();
		}
		}]">
		<form id="user_reg_regForm" method="post">
			<table>
				<tr>
					<th>登录名</th>
					<td><input name="logname" class="easyui-validatebox" data-options="required:true,validType:'logname',invalidMessage:'',missingMessage:'该项必填'" /></td>
				</tr>
				<tr>
				<th style="font-size:15px;font-weight:bold;">姓名</th>
				<td><input name="name" class="easyui-validatebox" data-options="required:true,validType:'chinese'"/>
				</td>
			</tr>
			<tr>
				<th style="font-size:15px;font-weight:bold;">性别</th>
				<td><input name="gender" class="easyui-combobox"  data-options="panelHeight:'auto',required:true,editable:false,valueField: 'label',textField: 'value',data: [{label: '男',value: '男'},{label: '女',value: '女'}]" />
				</td>
			</tr>
			<tr>
				<th style="font-size:15px;font-weight:bold;">预留手机号</th>
				<td><input name="telephone" class="easyui-validatebox" data-options="required:true,validType:'phoneOrMobile'"/>
				</td>
			</tr>
				<tr>
					<th>密码</th>
					<td><input name="pwd" type="password" class="easyui-validatebox" data-options="required:true,validType:'minLength[6]'" /></td>
				</tr>
				<tr>
					<th>重复密码</th>
					<td><input name="rePwd" type="password" class="easyui-validatebox" data-options="required:true,validType:'eqPwd[\'#user_reg_regForm input[name=pwd]\']'" /></td>
				</tr>
			</table>
		</form>
	</div>

